
// <copyright file="GenericToolStripControl.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The generic tool strip control.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Windows.Forms
{
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;

    /// <summary>
    /// The generic tool strip control.
    /// </summary>
    /// <typeparam name="T">
    /// </typeparam>
    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
    public class GenericToolStripControl<T> : ToolStripControlHost
        where T : Control, new()
    {
        #region Constructors and Finalizers

        /// <summary>
        /// Initializes a new instance of the <see cref="GenericToolStripControl{T}"/> class.
        /// </summary>
        public GenericToolStripControl()
            : base(new T())
        {
        }

        #endregion Constructors and Finalizers

        #region Public Properties

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        public override string Text
        {
            get
            {
                return this.Control.Text;
            }

            set
            {
                this.Control.Text = value;
            }
        }

        /// <summary>
        /// Gets the wrapped control.
        /// </summary>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public T WrappedControl
        {
            get
            {
                return this.Control as T;
            }
        }

        #endregion Public Properties
    }
}
